import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "*", //输错路由回首页
    redirect: "/404",
    hidden: true,
    meta: {
      keepAlive: false,
      title: "error"
    }
  },
  //404
  {
    path: "/404",
    name: "notFound",
    component: () => import("../views/error/NotFound.vue"),
    meta: {
      keepAlive: false,
      title: "404"
    },
    hidden: true
  },
  {
    path: "/home",
    name: "home",
    component: Home,
    meta: {
      title: "首页",
      keepAlive: false,
      requireAuth: true
    },
    children: [
      {
        path: "/page1",
        name: "page1",
        component: () => import("../views/page1/index.vue"),
        meta: {
          title: "第一页",
          requireAuth: true,
          keepAlive: false
        }
      },
      {
        path: "/page2",
        name: "page2",
        title: "page2",
        component: () => import("../views/page2/index.vue"),
        meta: {
          title: "第二页",
          requireAuth: true,
          keepAlive: false
        }
      }
    ]
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
